package tcp;

import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;

public class multithreadservertcp {
	public static void main(String[] args) throws Exception{
		ServerSocket svr=new ServerSocket(6666);
		System.out.println("anh dang doi em o cong 8888");
		while(true){
			Socket soc=svr.accept();
			new Thread(new Processing(soc)).start();
			svr.close();
		}
	}
}
class Processing implements Runnable{
	private Socket soc;
	public Processing(Socket soc) {
		this.soc=soc;
	}
	@Override
	public void run() {
		// TODO Auto-generated method stub
		try{
			Scanner input=new Scanner(soc.getInputStream());
			String request=input.nextLine();
			String response="From server:"+request.toUpperCase();
			PrintWriter out =new PrintWriter(soc.getOutputStream(),true);
			out.println(response);
			input.close();
		}
		catch(Exception e){
			e.getStackTrace();
		}
	}
}